   
           
 
            DECLARE	@return_value int,
            @resultsql_1 nvarchar(max)
            EXEC	@return_value = [dbo].[GenerateTaskList]
            @table_name = N'GoodsMasterKeyRelation',
            @table_Short = N'GC',
            @tableid = N'*',
            @SysID = N'1',
            @conditions = N'1=2',
            @resultsql_1 = @resultsql_1 OUTPUT
  
                 update ServiceList set Type='DELETE',TaskID='1000010206',ServiceID=b.TableID+'1000010206',Description='DB_GoodsMasterKeyRelation_DELETE_BY_InstanceID',Conditions='InstanceID=@InstanceID' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000001';
                 update ServiceList set Type='INSERT',TaskID='1000010204',ServiceID=b.TableID+'1000010204',Description='DB_GoodsMasterKeyRelation_INSERT',Conditions='***' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000002';
                 update ServiceList set Type='SELECT_ALL',TaskID='1000010208',ServiceID=b.TableID+'1000010208',Description='DB_GoodsMasterKeyRelation_SELECT_ALL',Conditions='***' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000003';
                 update ServiceList set Type='SELECT_BY_InstanceID',TaskID='1000010210',ServiceID=b.TableID+'1000010210',Description='DB_GoodsMasterKeyRelation_SELECT_BY_InstanceID',Conditions='InstanceID=@InstanceID' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000004';
                 update ServiceList set Type='SELECT_LIKE',TaskID='1000010205',ServiceID=b.TableID+'1000010205',Description='DB_GoodsMasterKeyRelation_SELECT_LIKE',Conditions='SysID=@SysID' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000005';
                 update ServiceList set Type='STRUCTURE',TaskID='1000010207',ServiceID=b.TableID+'1000010207',Description='DB_GoodsMasterKeyRelation_STRUCTURE',Conditions='***' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000006';
                 update ServiceList set Type='UPDATE',TaskID='1000010209',ServiceID=b.TableID+'1000010209',Description='DB_GoodsMasterKeyRelation_UPDATE_BY_InstanceID',Conditions='InstanceID=@InstanceID' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000007';
                 update ServiceList set Type='SELECT',TaskID='1000010216',ServiceID=b.TableID+'1000010216',Description='IX_GoodsMasterKeyRelation',Conditions='SysID=@SysID and KeyDefType=@KeyDefType and GoodsTypeKey=@GoodsTypeKey and GoodsTypeKeyDefKey=@GoodsTypeKeyDefKey and GoodsKey=@GoodsKey' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000008';
                 update ServiceList set Type='SELECT',TaskID='1000010218',ServiceID=b.TableID+'1000010218',Description='IX_GoodsMasterKeyRelation_Key',Conditions='SysID=@SysID and KeyDefType=@KeyDefType and GoodsTypeKey=@GoodsTypeKey and GoodsTypeKeyDefKey=@GoodsTypeKeyDefKey and GoodsKey=@GoodsKey' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000009';
                 update ServiceList set Type='SELECT',TaskID='1000010223',ServiceID=b.TableID+'1000010223',Description='IX_GoodsMasterKeyRelation_LikeAny',Conditions='SysID=@SysID' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000010';
                 update ServiceList set Type='SELECT',TaskID='1000010224',ServiceID=b.TableID+'1000010224',Description='IX_GoodsMasterKeyRelation_SysID',Conditions='SysID=@SysID' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000011';
                 update ServiceList set Type='SELECT',TaskID='1000010221',ServiceID=b.TableID+'1000010221',Description='IX_GoodsType',Conditions='SysID=@SysID and GoodsTypeKey=@GoodsTypeKey' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000012';
                 update ServiceList set Type='SELECT',TaskID='1000010220',ServiceID=b.TableID+'1000010220',Description='IX_GoodsTypeKeyDef',Conditions='SysID=@SysID and KeyDefType=@KeyDefType and GoodsTypeKey=@GoodsTypeKey and GoodsTypeKeyDefKey=@GoodsTypeKeyDefKey' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000013';
                 update ServiceList set Type='SELECT',TaskID='1000010226',ServiceID=b.TableID+'1000010226',Description='TX_GoodsMasterKeyRelation',Conditions='SysID=@SysID and KeyDefType=@KeyDefType and GoodsTypeKey=@GoodsTypeKey and GoodsTypeKeyDefKey=@GoodsTypeKeyDefKey and GoodsKey=@GoodsKey' from ServiceList a, TableList b where a.TableName='GoodsMasterKeyRelation' and a.TableName=b.TableName and ServiceID=b.TableID+'1000000014';
 
                USE [LANSUNERP]
                GO
                SET ANSI_NULLS ON
                GO
                SET QUOTED_IDENTIFIER ON
                GO
                SET ANSI_PADDING ON
                GO
				 DROP TABLE [dbo].[GoodsMasterKeyRelationQueryCond]
                GO
                CREATE TABLE [dbo].[GoodsMasterKeyRelationQueryCond](
                [QueryType] [nvarchar](50) NOT NULL,[ConditionType] [nvarchar](250) NOT NULL,[Reason1] [nvarchar](100) NULL,[InstanceID] [nvarchar](250) NULL,
[InstanceKey] [nvarchar](250) NULL,
[SysID] [nvarchar](10) NULL,
[KeyInstanceTable] [nvarchar](100) NULL,
[KeyDefType] [nvarchar](10) NULL,
[GoodsTypeKey] [nvarchar](2) NULL,
[GoodsTypeKeyDefKey] [nvarchar](40) NULL,
[GoodsKey] [nvarchar](50) NULL,
[GoodsKeyID] [nvarchar](50) NULL,
[PositionID] [int] NULL,
[LongDes] [nvarchar](250) NULL,
[ShortDes] [nvarchar](100) NULL,
[MKeyInstanceTable] [nvarchar](100) NULL,
[MKeyDefType] [nvarchar](10) NULL,
[MGoodsTypeKey] [nvarchar](2) NULL,
[MGoodsTypeKeyDefKey] [nvarchar](40) NULL,
[MGoodsKey] [nvarchar](50) NULL,
[SKeyInstanceTable] [nvarchar](100) NULL,
[SKeyDefType] [nvarchar](10) NULL,
[SGoodsTypeKey] [nvarchar](2) NULL,
[SGoodsTypeKeyDefKey] [nvarchar](40) NULL,
[SGoodsKey] [nvarchar](50) NULL,
[UGoodsKey] [nvarchar](50) NULL,
[SubStatus] [nvarchar](max) NULL,
[Status] [nvarchar](50) NULL,
[LastPositionID] [int] NULL,
[FrstUser] [nvarchar](10) NULL,
[FrstDate] [datetime] NULL,
[LastUser] [nvarchar](10) NULL,
[LastDate] [datetime] NULL 
 )  

GO

SET ANSI_PADDING OFF
GO
                            DECLARE	@return_value int,
            @resultsql_1 nvarchar(max)
            EXEC	@return_value = [dbo].[GenerateTaskList]
            @table_name = N'GoodsMasterKeyRelationQueryCond',
            @table_Short = N'GC',
            @tableid = N'*',
            @SysID = N'1',
            @conditions = N'1=2',
            @resultsql_1 = @resultsql_1 OUTPUT
            GO
            INSERT INTO [LANSUNERP].[dbo].[GoodsMasterKeyRelationQueryCond]
           ([QueryType],[ConditionType],[SysID])VALUES ('QueryOnly','IX_GoodsMasterKeyRelation_SysID','1')
GO 
 
 BEGIN TRANSACTION
 SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
 DROP INDEX IX_GoodsMasterKeyRelation ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX IX_GoodsMasterKeyRelation ON dbo.GoodsMasterKeyRelation
 (
SysID,KeyDefType,GoodsTypeKey,GoodsTypeKeyDefKey,GoodsKey
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
 DROP INDEX IX_GoodsMasterKeyRelation_Key ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX IX_GoodsMasterKeyRelation_Key ON dbo.GoodsMasterKeyRelation
 (
SysID,KeyDefType,GoodsTypeKey,GoodsTypeKeyDefKey,GoodsKey
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
 DROP INDEX IX_GoodsMasterKeyRelation_LikeAny ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX IX_GoodsMasterKeyRelation_LikeAny ON dbo.GoodsMasterKeyRelation
 (
SysID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
 DROP INDEX IX_GoodsMasterKeyRelation_SysID ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX IX_GoodsMasterKeyRelation_SysID ON dbo.GoodsMasterKeyRelation
 (
SysID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
 DROP INDEX IX_GoodsType ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX IX_GoodsType ON dbo.GoodsMasterKeyRelation
 (
SysID,GoodsTypeKey
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
 DROP INDEX IX_GoodsTypeKeyDef ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX IX_GoodsTypeKeyDef ON dbo.GoodsMasterKeyRelation
 (
SysID,KeyDefType,GoodsTypeKey,GoodsTypeKeyDefKey
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
 DROP INDEX TX_GoodsMasterKeyRelation ON dbo.GoodsMasterKeyRelation
GO
CREATE NONCLUSTERED INDEX TX_GoodsMasterKeyRelation ON dbo.GoodsMasterKeyRelation
 (
SysID,KeyDefType,GoodsTypeKey,GoodsTypeKeyDefKey,GoodsKey
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.GoodsMasterKeyRelation  SET (LOCK_ESCALATION = TABLE)
GO
COMMIT




/*DECLARE	@return_value int
EXEC	@return_value = [dbo].[GenereateQueryCond]
SELECT	'Return Value' = @return_value
GO
*/
 

